package main

import (
	"fmt"
	"kandy/app/controller"
	"kandy/framework"
	"net/http"
	"time"
)

func init() {
	//初始化
	framework.InitDB()
	framework.CreateTable()
}

func main() {
	//开启web服务
	server := &http.Server{
		Addr:        ":8088",
		Handler:     framework.Router,
		ReadTimeout: 5 * time.Second,
	}
	RegisterRouter(framework.Router)
	err := server.ListenAndServe()
	if err != nil {
		fmt.Println("star server error:", err)
	}
	fmt.Println("start server success")
}

func RegisterRouter(handler *framework.RouterHandler) {
	new(controller.UserController).Router(handler)
}
